home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-08 | 5.8 KB | 228 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWGadget.cpp
- // Release Version: $ 1.0d11 $
- //
- // Copyright: © 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWFrameW.hpp"
-
- #ifndef FWGADGET_H
- #include "FWGadget.h"
- #endif
-
- #ifndef FWFRAME_H
- #include "FWFrame.h"
- #endif
-
- #ifndef FWUTIL_H
- #include "FWUtil.h"
- #endif
-
- // ----- OS Layer -----
-
- #ifndef FWEVENT_H
- #include "FWEvent.h"
- #endif
-
- #ifndef FWGRGLOB_H
- #include "FWGrGlob.h"
- #endif
-
- #ifndef FWGRUTIL_H
- #include "FWGrUtil.h"
- #endif
-
- #ifndef FWODGEOM_H
- #include "FWODGeom.h"
- #endif
-
- #ifndef FWFCTINF_H
- #include "FWFctInf.h"
- #endif
-
- #ifndef FWWINDOW_H
- #include "FWWindow.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef SOM_ODFacet_xh
- #include <Facet.xh>
- #endif
-
- #ifndef SOM_ODCanvas_xh
- #include <Canvas.xh>
- #endif
-
- #ifndef SOM_ODTransform_xh
- #include <Trnsform.xh>
- #endif
-
- //========================================================================================
- // Runtime Informations
- //========================================================================================
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export on
- #endif
-
- #ifdef FW_BUILD_MAC
- #pragma segment fwgadgts
- #endif
-
- //========================================================================================
- // Forward declarations
- //========================================================================================
-
- class FW_CLASS_ATTR ODTransform;
-
- //========================================================================================
- // CLASS FW_CGadget
- //========================================================================================
-
- FW_DEFINE_CLASS_M1(FW_CGadget, FW_CView)
-
- //----------------------------------------------------------------------------------------
- // FW_CGadget::FW_CGadget
- //----------------------------------------------------------------------------------------
-
- FW_CGadget::FW_CGadget(Environment* ev,
- FW_CView* container, ODID id,
- const FW_CRect& bounds,
- int contentSpace) :
- FW_CView(ev, container, id, TRUE, kNoPriority, bounds, FW_kZeroPoint, NULL, contentSpace)
- {
- FW_ASSERT(container != NULL);
- // initializer.AddGadget(this); *LSD use CViewInitializer?
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CGadget::FW_CGadget
- //----------------------------------------------------------------------------------------
-
- FW_CGadget::FW_CGadget(Environment* ev, FW_CReadableStream& archive) :
- FW_CView(ev)
- {
- // initializer.AddGadget(this);
-
- #if 0 // *LSD to see later
- // Read gadget container fields
- FW_CView* container;
- FW_READ_DYNAMIC_OBJECT(archive, &gadget, FW_CGadget);
-
- // Read event handler fields
- FW_MEventHandler::EventIdentifier id;
- archive >> id;
- SetIdentifier(ev, id);
-
- unsigned long gadgetCnt;
-
- // Need to read subgadgets here because subgadget will call by AdoptGadget method which is
- // a virtual method that needs to be dispatched correctly.
-
- archive >> gadgetCnt;
- while (gadgetCnt--)
- {
- FW_CGadget* gadget;
- FW_READ_DYNAMIC_OBJECT(archive, &gadget, FW_CGadget);
- }
-
- archive >> fLocation;
- archive >> fSize;
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CGadget::~FW_CGadget
- //----------------------------------------------------------------------------------------
-
- FW_CGadget::~FW_CGadget()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CGadget::Write
- //----------------------------------------------------------------------------------------
-
- void FW_CGadget::Write(FW_CWritableStream& archive, const void* gadget)
- {
- ((FW_CGadget *) gadget)->Flatten(archive);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CGadget::Flatten
- //----------------------------------------------------------------------------------------
-
- void FW_CGadget::Flatten(FW_CWritableStream& archive) const
- {
- #if 0
- Environment* ev = ::somGetGlobalEnvironment();
-
- archive << fLocation;
- archive << fSize;
-
- archive << CountGadgets(ev);
-
- FW_CGadgetIterator iter(ev, this);
- for (FW_CGadget* gadget = (FW_CGadget*)iter.First(ev);
- iter.IsNotComplete(ev); gadget = (FW_CGadget*)iter.Next(ev))
- {
- FW_WRITE_DYNAMIC_OBJECT(archive, &gadget, FW_CGadget);
- }
- #endif
- }
-
-
- //========================================================================================
- // CLASS FW_CGadgetInitializer
- //========================================================================================
- // *LSD not used anymore (for now)
- #if 0
-
- //----------------------------------------------------------------------------------------
- // FW_CGadgetInitializer::FW_CGadgetInitializer
- //----------------------------------------------------------------------------------------
-
- FW_CGadgetInitializer* FW_CGadgetInitializer::fInitializerStack;
-
- FW_CGadgetInitializer::FW_CGadgetInitializer(Environment* ev) :
- fGadgetsToInitialize(new FW_CPrivOrderedCollection),
- fNextInitializer(fInitializerStack)
- {
- fInitializerStack = this;
- }
-
- FW_CGadgetInitializer::~FW_CGadgetInitializer()
- {
- Environment* ev = ::somGetGlobalEnvironment();
-
- FW_COrderedCollectionIterator ite(fGadgetsToInitialize);
- for (FW_CGadget* gadget = (FW_CGadget *) ite.First();
- ite.IsNotComplete();
- gadget = (FW_CGadget *) ite.Next())
- {
- gadget->PostCreate(ev);
- }
-
- delete fGadgetsToInitialize;
-
- fInitializerStack = fInitializerStack->fNextInitializer;
- }
-
- void FW_CGadgetInitializer::AddGadget(FW_CGadget* gadgetToInitialize)
- {
- fGadgetsToInitialize->AddLast(gadgetToInitialize);
- }
-
- FW_CGadgetInitializer& FW_CGadgetInitializer::GetGadgetInitializer()
- {
- FW_ASSERT(fInitializerStack != NULL);
-
- return *fInitializerStack;
- }
-
- #endif // CLASS FW_CGadgetInitializer
-